package com.lhy.framework.test.common;

import com.lhy.framework.beans.BeansException;
import com.lhy.framework.beans.factory.factory.BeanPostProcessor;
import com.lhy.framework.test.bean.UserService;

/**
 * @ClassName MyBeanPostProcessor
 * @Description
 * @Author lihaiyang
 * @Date 2022/9/12 11:14
 * @Version 1.0
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(String beanName, Object bean) throws BeansException {
        if ("userService".equals(beanName)) {
            UserService userService = (UserService) bean;
            userService.setLocation("改为：北京");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(String beanName, Object bean) throws BeansException {
        return bean;
    }
}
